package com.ztstkj.lzservices.utils

import android.annotation.SuppressLint
import android.icu.text.SimpleDateFormat
import java.util.Calendar
import java.util.Date
import java.util.Locale


object DateTimeUtil {
    fun getNowDateField(): DateField {
        var calendar = Calendar.getInstance()
        var year = calendar.get(Calendar.YEAR)
        var month = calendar.get(Calendar.MONTH) + 1
        var day = calendar.get(Calendar.DAY_OF_MONTH)
        var hour = calendar.get(Calendar.HOUR_OF_DAY)
        var minute = calendar.get(Calendar.MINUTE)
        var second = calendar.get(Calendar.SECOND)
        var dayOfweek = calendar.get(Calendar.DAY_OF_WEEK) - 1
        if (dayOfweek == 0) dayOfweek = 7
        var dateTime =
            SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()).format(calendar.time)
        return DateField(year, month, day, hour, minute, second, dayOfweek, dateTime)
    }

    @SuppressLint("SimpleDateFormat")
    fun getNowDate(): String {
        return SimpleDateFormat("yyyy-MM-dd").format(Date())
    }
    @SuppressLint("SimpleDateFormat")
    fun getNowDateTime(): String {
        return SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Date())
    }
}

class DateField(
    var year: Int,
    var month: Int,
    var day: Int,
    var hour: Int,
    var minute: Int,
    var second: Int,
    var dayOfweek: Int,
    var dateTime: String
)